package com.ziyucoding.springboot.labs.lab4.concurrentdemo.example.atomic;

import com.ziyucoding.springboot.labs.lab4.concurrentdemo.annoations.ThreadSafe;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.atomic.AtomicReference;

/**
 * Atomic 示例4
 *
 * @author ziyucoding
 * @date 2022-10-25
 **/
@Slf4j
@ThreadSafe
public class AtomicExample4 {

    private static AtomicReference<Integer> count = new AtomicReference<>(0);

    public static void main(String[] args) {
        count.compareAndSet(0, 8);
        count.compareAndSet(1, 9);
        count.compareAndSet(8, 6);
        // count:6
        log.info("count:{}", count.get());
    }
}
